package com.example.imooccommon.repository.constsrepository;

import com.example.imooccommon.entity.consts.ConstsCollege;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author Anita
 * @Date 2018/1/16 18:12
 */
public interface ConstsCollegeRepository extends JpaRepository<ConstsCollege,Long> {

    public ConstsCollege findByCode(String code);


    public ConstsCollege findByIdAndDel(Long id,Integer del);

    @Transactional
    @Modifying
    @Query(value = "update consts_college c set c.del = 1 where c.id=?1",nativeQuery = true)
    void updateDelByConstsCollegeId(Long id);

    @Transactional
    @Modifying
    @Query(value = "delete from consts_college where id =:id",nativeQuery = true)
    void deleteById(@Param("id") Long id);


}
